package com.xuanyuanxinyu.func.executor

import kotlinx.coroutines.ExecutorCoroutineDispatcher
import kotlinx.coroutines.Runnable
import java.util.concurrent.Executor
import java.util.concurrent.Executors
import kotlin.coroutines.CoroutineContext

/**
 * @FileName:
 * @Description:
 * @author ken.luo
 * @date 2023/4/4
 * @version V1.0
 * @email 424533553@qq.com
 */
object SingleDispatcher : ExecutorCoroutineDispatcher() {
    private val myExecutor : Executor by lazy {
        Executors.newSingleThreadExecutor()
    }
    override val executor : Executor
        get() = myExecutor
    
    override fun close() {
    
    }
    
    override fun dispatch(context : CoroutineContext,block : Runnable) {
        executor.execute(block)
    }
    
    
    
}
